public class Solution {
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        ListNode newNode = new ListNode(0);
        ListNode newNodeCur = newNode;
        ListNode cur1 = l1;
        ListNode cur2 = l2;
        while (cur1 != null && cur2 != null) {
            if (cur1.val > cur2.val) {
                newNodeCur.next = cur2;
                cur2 = cur2.next;
            } else {
                newNodeCur.next = cur1;
                cur1 = cur1.next;
            }
            newNodeCur = newNodeCur.next;
        }
        if (cur1 != null) {
            newNodeCur.next = cur1;
        }
        if (cur2 != null) {
            newNodeCur.next = cur2;
        }
        return newNode.next;
    }
}


